<?php

set_include_path('f:/http/kodform4/lib');
require_once 'Kodform.php';
require_once 'Kodform/Element/Field.php';
require_once 'Kodform/Validator/Regex.php';
require_once 'Kodform/Validator/Size.php';
require_once 'Kodform/Validator/Required.php';
require_once 'Kodform/Element/Submit.php';
require_once 'Kodform/Element/Select.php';
require_once 'Kodform/Element/Text.php';
require_once 'Kodform/Element/Reset.php';

$form = new Kodform("login", 0, "");

$fusername =& $form->addElement(new Kodform_Element_Field("username", "Username", Kodform_Element_Field::text, null, "Please enter username"));
$fusername->addValidator(new Kodform_Validator_Regex("'\w*'", "Username can hold only numbers and letters"));
$fusername->addValidator(new Kodform_Validator_Size(10, 4, "Username must be 4 to 10 letters long."));
   	
$fpassword =& $form->addElement(new Kodform_Element_Field("password", "Password", Kodform_Element_Field::password, null, "Please enter password"));
$fpassword->addValidator(new  Kodform_Validator_Regex("'\w*'", "Password can hold only numbers and letters."));
$fpassword->addValidator(new Kodform_Validator_Size(10, 4, "Password must be 4 to 10 letters long."));

$fhidden =& $form->addElement(new Kodform_Element_Field("hidden", "Hidden", Kodform_Element_Field::hidden, "hiddenValue", "Hidden element does not exists???"));
$fhidden->addValidator(new  Kodform_Validator_Regex("'\w*'", "Hidden element contains forbiden charachters"));
$fhidden->addValidator(new Kodform_Validator_Size(15, 4, "hidden element must be 4 to 15 letters long."));

$ftext =& $form->addElement(new Kodform_Element_Text("text", "Text Box", 6, 25, "This is text box"));
$ftext->addValidator(new Kodform_Validator_Required("Text box must contain some text."));

$fselect =& $form->addElement(new Kodform_Element_Select("single_select", "List Box", "Usuported options submitted."));
$fselect->addOption("Elan", 0);
$fselect->addOption("Grand Soleil", 1);
$fselect->addOption("Hunter", 2);
$fselect->addOption("Salona", 3, true);

$fmselect =& $form->addElement(new Kodform_Element_Select("multi_select", "Multi List Box", "Usuported options submitted.", true));
$fmselect->addOption("Elan", 0, true);
$fmselect->addOption("Grand Soleil", 1);
$fmselect->addOption("Hunter", 2, true);
$fmselect->addOption("Salona", 3);

$form->addElement(new Kodform_Element_Submit("slogin", "Login"));
$form->addElement(new Kodform_Element_Reset("sreset", "Reset"));
?>

<html>
<head>
<title>Kodform All Elements Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<?php
if($form->isSubmited() && $form->isValid()){
	?>
	<div>Username: <?php print $form->username->getValue();?></div>
	<div>Password: <?php print $form->password->getValue();?></div>
	<div>Hidden: <?php print $form->hidden->getValue();?></div>
	<div>Text Box: <?php print $form->text->getValue();?></div>
	<div>Single Select: <?php print $form->single_select->getValue();?></div>
	<div>Multi Select: <?php var_dump($form->multi_select->getValue());?></div>
	<div><a href="">Test Them Again</a></div>
	<?php
}
else
	print $form->display();
     	
?>
</body>
</html>